package cn.new7as.cas5s.ui.record;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.OnHttpListener;

import java.util.List;

import cn.new7as.cas5s.ui.slideshow.BaseActivity;
import cn.new7as.cas5s.databinding.ActivitySendtypeBinding;
import cn.new7as.cas5s.tool.util.Utils;
import cn.new7as.cas5s.ui.easy.netapi.HttpData;
import cn.new7as.cas5s.ui.easy.netapi.IssueTypeApi;


public class SendTypeActivity extends BaseActivity {

    ActivitySendtypeBinding binding;

    @SuppressLint("MissingPermission")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySendtypeBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setop("Type of Issue", true);
        initV();
    }

    int issuetype;
    int issuetypeord;

    public void setlis(ImageView... text) {

        for (int i = 0; i < text.length; i++) {
            text[i].setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                }
            });
        }

    }

    List<IssueTypeApi.IssData> result1;

    void ged() {
        show();
        EasyHttp.get(this).api(new IssueTypeApi(getunique())).request(new OnHttpListener<HttpData<List<IssueTypeApi.IssData>>>() {


            @Override
            public void onHttpSuccess(@NonNull HttpData<List<IssueTypeApi.IssData>> result) {
                hide();
                result1 = result.getResult();
                setchoose(0,result1.get(0).mulGopfNwomn);
                result1.get(0).isok = true;
                IssuAdapter adapter = new IssuAdapter(result1, SendTypeActivity.this);
                binding.issugride.setAdapter(adapter);

            }

            @Override
            public void onHttpFail(@NonNull Throwable throwable) {
                deal(throwable);
            }
        });

    }

    public void setchoose(int position,int isJumpOrders) {
        issuetype = result1.get(position).issueTypeId;
        issuetypeord=isJumpOrders;
        binding.content.setText(result1.get(position).content);
    }


    @Override
    public void initV() {
        super.initV();
        ged();
        binding.verifyme.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (issuetypeord == 1)
                    Utils.goextra(SendTypeActivity.this, SendOrderMsgActivity.class, issuetype + "");
                else
                    Utils.goextra(SendTypeActivity.this, SendMsgActivity.class, issuetype + "");

                finish();
            }
        });
    }
}